/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package forms;

import com.sun.lwuit.ButtonGroup;
import com.sun.lwuit.Command;
import com.sun.lwuit.Container;
import com.sun.lwuit.Label;
import com.sun.lwuit.RadioButton;
import com.sun.lwuit.TextField;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.layouts.BoxLayout;
import entidade.AppHelper;
import javax.microedition.lcdui.Display;



/**
 *
 * @author ademar.victorino
 */
public class ConfigOperadoraForm extends AbstractForm{

    TextField txNumOp = new TextField();
    Label lbExample = new Label();
    
    public ConfigOperadoraForm() {
        super("Configurar chamada");

        Display d = Display.getDisplay(AppHelper.getInstance().getMidlet());
        int w = d.getCurrent().getWidth();

        Container cont = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        cont.setWidth(w);
        cont.addComponent(new Label("Usar operadora:"));
        ButtonGroup rg = new ButtonGroup();
        
        RadioButton radioYes = new RadioButton("sim");
        RadioButton radioNo = new RadioButton("não");
        rg.add(radioYes);
        rg.add(radioNo);
        cont.addComponent(radioYes);
        cont.addComponent(radioNo);

        cont.addComponent(new Label("Código operadora:"));
        txNumOp.setColumns(2);
        txNumOp.setMaxSize(2);
        cont.addComponent(txNumOp);
        cont.addComponent(lbExample);

        addComponent(cont);
        radioYes.setSelected(true);

        
        addCommand(new Command("Voltar") {

            public void actionPerformed(ActionEvent evt) {

                InicialForm.getInstance().show();

            }
        });

        addCommand(new Command("Salvar") {

            public void actionPerformed(ActionEvent evt) {

                InicialForm.getInstance().show();

            }
        });
        
    }
    
    public void setLabelText(){
        String text = "0";/*
        UsuarioConfig uc = AppHelper.getInstance().getUc();
        Cidade cit = (Cidade)MObjectController.createMObject(MObjectLoader.TYPE_CIDADE, uc.getCidadeId());
        
        if(txNumOp.getText() != null || txNumOp.getText().trim().length() != 0){
            if(txNumOp.getText() != null || txNumOp.getText().trim().length() == 1){
                text += txNumOp + "_" + String.valueOf(cit.getDdd().intValue()) + "XXXX-XXXX";
            }else{
                text += txNumOp + String.valueOf(cit.getDdd().intValue()) + "XXXX-XXXX";
            }
        }else{
            text += "__" + String.valueOf(cit.getDdd().intValue()) + "XXXX-XXXX";
        }
        lbExample.setText(text);
                           */
    }
}
